home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17072 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: kalabsha.trin.cam.ac.uk!93bb
  2. From: 93bb@eng.cam.ac.uk (Ben Blaukopf)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: easy c++ question
  5. Date: Sat, 13 Apr 1996 15:38:56
  6. Organization: University of Cambridge, England
  7. Message-ID: <93bb.38.000FA695@eng.cam.ac.uk>
  8. References: <316901DA.3138C677@ablecom.net> <66W25t5UoNB@jth.ping.de> <Pine.OSF.3.91.960411092945.20958C-100000@bud.cc.swin.edu.au>
  9. NNTP-Posting-Host: kalabsha.trin.cam.ac.uk
  10. X-Newsreader: Trumpet for Windows [Version 1.0 Rev A]
  11.  
  12. In article <Pine.OSF.3.91.960411092945.20958C-100000@bud.cc.swin.edu.au> John Joseph Newbigin <079519@bud.cc.swin.edu.au> writes:
  13. >Subject: Re: easy c++ question
  14. >From: John Joseph Newbigin <079519@bud.cc.swin.edu.au>
  15. >Date: Thu, 11 Apr 1996 09:33:04 +1000
  16.  
  17. >On 9 Apr 1996, Jens Theisen wrote:
  18.  
  19. >> You should be right. Constructors are called implicitly when an object of  
  20. >> this class is created. Perhaps your constructor hasn't the same parameter  
  21. >> list than the one your are using to create the object.
  22. >> 
  23. >....Sometimes...
  24. >if you have a class myclass with a constructor and you do
  25.  
  26. >myclass *a;
  27. >a=new myclass[5];
  28.  
  29. >the constructor is not called for every member (a[0], a[1]..)
  30. >Does this help?
  31. > Newbs
  32. The ctor certainly is called for every member. Furthermore, when you
  33. delete the array
  34. delete[] a;
  35. the dtor is also called for every member. 
  36.  
  37. a = new myclass[5]
  38.  
  39. allocates a block of memory big enough for 5 objects, and constructs them.
  40.  
  41. Ben Blaukopf
  42.